package com.epro.dx.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;

import com.epro.dx.R;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import com.weipu.common.DXApplication;
import com.weipu.common.DXApplication.TrackerName;

/**
 * 分享页面
 * 
 * @author  hjd008
 * @version  [版本号, 2015-1-13]
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
public class ShareAllActivity extends BaseFragmentActivity implements OnClickListener
{
    private Button facebook, twitter, youtube, officialblog, cancle;
    
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        Tracker tracker = DXApplication.getContext().getTracker(TrackerName.APP_TRACKER);
        tracker.setScreenName(ShareAllActivity.class.getSimpleName());
        tracker.send(new HitBuilders.ScreenViewBuilder().build());
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_shareall);
        initView();
    }
    
    private void initView()
    {
        facebook = (Button)findViewById(R.id.facebook);
        twitter = (Button)findViewById(R.id.twitter);
        youtube = (Button)findViewById(R.id.youtube);
        officialblog = (Button)findViewById(R.id.officialblog);
        cancle = (Button)findViewById(R.id.cancle);
        facebook.setOnClickListener(this);
        twitter.setOnClickListener(this);
        youtube.setOnClickListener(this);
        officialblog.setOnClickListener(this);
        cancle.setOnClickListener(this);
        
    }
    
    public void onClick(View v)
    {
        Intent it = new Intent(Intent.ACTION_VIEW);
        switch (v.getId())
        {
            case R.id.facebook:
                
                it.setData(Uri.parse("http://www.facebook.com/"));
                
                it = Intent.createChooser(it, null);
                
                startActivity(it);
                
                break;
            case R.id.twitter:
                
                it.setData(Uri.parse("http://www.twitter.com/"));
                
                it = Intent.createChooser(it, null);
                
                startActivity(it);
                break;
            case R.id.youtube:
                it.setData(Uri.parse("http://www.youtube.com/"));
                it = Intent.createChooser(it, null);
                startActivity(it);
                break;
            case R.id.officialblog:
                
                it.setData(Uri.parse("http://blog.dealextreme.com/"));
                
                it = Intent.createChooser(it, null);
                
                startActivity(it);
                break;
            default:
            case R.id.cancle:
                finish();
                break;
        }
    }
}
